package com.indusfo.spc.controller;

import com.indusfo.spc.aspect.SystemControllerLog;
import com.indusfo.spc.pojo.ProcessBom;
import com.indusfo.spc.service.ProcessBomService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @ProjectName: IEIS2-COM
 * @Package: com.indusfo.spc.controller
 * @ClassName: ProcessBomController
 * @Author: 熊冰
 * @Description: 流程关联物料
 * @Date: 2019/9/4 16:42
 * @Version: 1.0
 */
@Controller
@RequestMapping("/processBom")
public class ProcessBomController {
    @Autowired
    private ProcessBomService processBomService;

    /**
     * 修改不良对策
     *
     * @param processBom
     * @return
     */
    @RequestMapping(value = "/updateProcessBom",method= RequestMethod.POST)
    @SystemControllerLog(description="修改不良对策")
    @ResponseBody
    public JSONObject updateProcessBom (ProcessBom processBom){

        JSONObject json=processBomService.updateProcessBom(processBom);

        return json;
    }

    /**
     * 查询
     *
     * @param
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/queryProcessBom")
    @SystemControllerLog(description="查询不良对策")
    @ResponseBody
    public JSONObject queryDep(ProcessBom processBom) {

        JSONObject json = processBomService.queryProcessBom(processBom);
        return json;

    }

    /**
     * 插入
     *
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/insertProcessBom", method= RequestMethod.POST)
    @SystemControllerLog(description="新增不良对策")
    @ResponseBody
    public JSONObject insertProcessBom(ProcessBom processBom) {

        JSONObject json = processBomService.insertProcessBom(processBom);
        return json;
    }

    /**
     * 启用/停用
     *
     * @param processBomIds, dataState
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/definesProcessBom", method= RequestMethod.POST)
    @SystemControllerLog(description="启用/停用不良对策")
    @ResponseBody
    public JSONObject definesProcessBom(@RequestParam("processBomIds")List<Integer>  processBomIds, Integer dataState) {

        JSONObject json = processBomService.deleteProcessBom(processBomIds, dataState);
        return json;
    }

    /**
     * 删除
     *
     * @param processBomIds, dataState
     * @return com.indusfo.spc.vo.JSONObject
     */
    @RequestMapping(value="/deleteProcessBom", method= RequestMethod.POST)
    @SystemControllerLog(description="删除不良对策")
    @ResponseBody
    public JSONObject delProcessBom(@RequestParam("processBomIds") List<Integer> processBomIds, Integer dataState) {

        dataState = 2;
        JSONObject json = processBomService.deleteProcessBom(processBomIds, dataState);
        return json;
    }
}
